/** @Date 上午11:38:30
  * @version 1.0.0
  * @author shangyd
  * Copyright (c) 2015
  */
package com.sdw.soft.common.argument.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import com.sdw.soft.activemq.vo.Notify;
import com.sdw.soft.common.argument.annotation.Search;

public class SecureModelAttributeMethodArgumentResolver implements
		HandlerMethodArgumentResolver {

	private static final Logger logger = LoggerFactory.getLogger(SecureModelAttributeMethodArgumentResolver.class);
	
	@Override
	public boolean supportsParameter(MethodParameter parameter) {
		Search search = parameter.getParameterAnnotation(Search.class);
		if(search != null){
			logger.info("参数匹配 ... ...");
			return true;
		}
		return false;
	}

	@Override
	public Object resolveArgument(MethodParameter parameter,
			ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
			WebDataBinderFactory binderFactory) throws Exception {
			Notify notify = new Notify();
			notify.setContent("hello handler method argument resolver ... ...");
			mavContainer.addAttribute("notify", notify.getContent());
		return notify;
	}

}
